#include "HouseEmitter.h"
#include "Constants.h"

HouseEmitter::HouseEmitter(TextureLoader * textureLoader, CubePileGrid * aCubePiles)
	: RandomTimeEmitter(aCubePiles, MIN_EMIT_TIME, MAX_EMIT_TIME)
{
	
}


void HouseEmitter::emitTo(CubePileGrid * cubePiles)
{
	HousePart * part = houseParts.at(houseParts.size() -1); 
	houseParts.pop_back();
	int xPos = (int)part->xPos;
	int zPos = (int)part->zPos;
	part->yPos = 8;
	cubePiles->at(xPos, zPos)->dropCube(part);
	cubePiles->at(xPos, zPos)->lock();
}

void HouseEmitter::add(HousePart * part)
{
	houseParts.push_back(part);	
}

bool HouseEmitter::isFinishedEmitting()
{
	return houseParts.size() == 0;
}
